n=1000
bhisop_board = [[0 for i in range(n)] for j in range(n)]
t = int(input())
for i in range(t):
x,y = map(int,input().split())
bhisop_board[x-1][y-1] = 1
total_attacks=0
for i in range(1,n):
curr_diag_bhisops_count=0
for j in range(i+1):
if bhisop_board[i-j][j]==1:
curr_diag_bhisops_count+=1
total_attacks+=(curr_diag_bhisops_count*(curr_diag_bhisops_count-1))//2
for j in range(1,n):
curr_diag_bhisops_count=0
for i in range(n-j):
if bhisop_board[n-1-i][j+i]==1:
curr_diag_bhisops_count+=1
total_attacks+=(curr_diag_bhisops_count*(curr_diag_bhisops_count-1))//2
for i in range(n-1,0,-1):
curr_diag_bhisops_count=0
for j in range(n-i):
if bhisop_board[i+j][j]==1:
curr_diag_bhisops_count+=1
total_attacks+=(curr_diag_bhisops_count*(curr_diag_bhisops_count-1))//2
for j in range(n):
curr_diag_bhisops_count=0
for i in range(n-j):
if bhisop_board[i][j+i]==1:
curr_diag_bhisops_count+=1
total_attacks+=(curr_diag_bhisops_count*(curr_diag_bhisops_count-1))//2
print(total_attacks)
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ll long long
#define endl '\n'
#define ld long double
#define pq priority_queue
#define pb emplace_back
#define Fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define loop(i, s, n) for(int i=s;i<n;i++)
#define rloop(i, s) for(int i=s;i>=0;i--)
#define sz(s) (int)s.size()
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<int, null_type,less_equal<>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<int, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k): It returns to an iterator to the kth element
//order_of_key(k) : It returns to the number of items that are strictly smaller than our item k
ll mod = 1073741824;
const int N = 1e6 + 7;
ll inf = 1e18;
ll mul(ll a, ll b){return (a % mod) * (b % mod) % mod;}
ll fastpow(ll a, ll b){if (b == 0)return 1;ll x = fastpow(a, b / 2);if (b % 2)return x * x * a;return x * x;}
ll fastpowmod(ll a, ll b, ll m){if (b == 0)return 1;ll x = fastpowmod(a, b / 2, m);if (b % 2)return mul(mul(x, x), a);return mul(x, x);}
ll extended_euc(ll a, ll b, ll &x, ll &y){if (a < 0){ll r = extended_euc(-a, b, x, y);x *= -1;return r;}if (b < 0){ll r = extended_euc(a, -b, x, y);y *= -1;return r;}if (b == 0){x = 1;y = 0;return a;}ll x1, y1;ll d = extended_euc(b, a % b, x1, y1);x = y1;y = x1 - y1 * (a / b);return d;}
ll dio(ll a, ll b, ll c, ll &x, ll &y, ll &found){ll g = extended_euc(a, b, x, y);found = c % g;if (found == 0){x *= c / g;y *= c / g;}return g;}
// ax=b(mod n)
// solve for x
vector<ll> modularequation(ll a, ll b, ll n){vector<ll> sol;ll x, y, g;g = extended_euc(a, n, x, y);if (b % g != 0)return sol;x = ((x * b / g) % n + n) % n;for (int i = 0; i < g; i++){sol.pb((x + i * n / g) % n);}sort(all(sol));return sol;}
ll inv(ll a, ll m){ll x, y;extended_euc(a, m, x, y);return (x % m + m) % m;}
ll inv2(ll a, ll m){return fastpowmod(a, m - 2, m);}
ll comb(ll n, ll m){ll z = 1;for (ll i = 1; i <= m; ++i){z = mul(mul(z, n - m + i), inv(i, mod));}return z;}
ll com(ll n, ll r){if (n < r)return 0;if (n == 1)return 1;if (r == 0)return 1;if (r == 1)return n;return (com(n - 1, r - 1) % mod + com(n - 1, r) % mod) %mod;}
int div(int A, int B, int M){if (A % M == 0)return (B / M) - (A / M) + 1;return (B / M) - (A / M);}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return a / gcd(a, b)*b;}
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, -1, 1, 1, -1};
auto cmp=[](int a,int b)
{
return a>b;
};
int main()
{
Fast;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int tc = 1;
//cin >> tc;
while (tc--)
{
int n;
cin>>n;
vector<int> d1(2001),d2(2001);
loop(i,0,n)
{
int x,y;
cin>>x>>y;
int r1,c1,r2,c2;
int mn=min(x-1,1000-y);
r1=x-mn,c1=y+mn;
d1[r1+c1-1]++;
mn=min(1000-x,1000-y);
r2=x+mn,c2=y+mn;
d2[1000-r2+c2]++;
}
ll ans=0;
loop(i,1,2002)
{
ll x=d1[i];
ll y=d2[i];
ans+=x*(x-1)/2;
ans+=y*(y-1)/2;
}
cout<<ans<<endl;
}
}
1110A - Parity | 1215B - The Number of Products |
604C - Alternative Thinking | 1204C - Anna Svyatoslav and Maps |
322A - Ciel and Dancing | 1689B - Mystic Permutation |
1711B - Party | 1702D - Not a Cheap String |
1714F - Build a Tree and That Is It | 1703F - Yet Another Problem About Pairs Satisfying an Inequality |
610A - Pasha and Stick | 1200A - Hotelier |
1091A - New Year and the Christmas Ornament | 1352B - Same Parity Summands |
1102A - Integer Sequence Dividing | 630B - Moore's Law |
1004A - Sonya and Hotels | 1680B - Robots |
1690A - Print a Pedestal (Codeforces logo) | 1295A - Display The Number |
1077A - Frog Jumping | 1714G - Path Prefixes |
1369C - RationalLee | 289B - Polo the Penguin and Matrix |
1716A - 2-3 Moves | 1670B - Dorms War |
1716B - Permutation Chain | 987A - Infinity Gauntlet |
1676G - White-Black Balanced Subtrees | 1716D - Chip Move |